<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>Layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" th:href="@{/layui/css/layui.css}"  media="all">
    <script th:src="@{/layui/layui.js}" charset="utf-8"></script>
</head>
<body>



<form class="layui-form" action="" id="form1">
<br>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单编码</label>
            <div class="layui-input-inline">
                <input type="hidden" name="id"  th:value="${order.id}">
                <input type="text" name="ordercode"  th:value="${order.ordercode}"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">商品名称</label>
            <div class="layui-input-inline">
                <input type="text" name="name"  th:value="${order.name}"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">供应商名称</label>
            <div class="layui-input-inline">
                <input type="tel" name="providername"  th:value="${order.providername}" autocomplete="off" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">是否付款</label>
            <div class="layui-input-inline">
                <input type="tel" name="ispay"  th:value="${order.ispay}" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-inline">
            <label class="layui-form-label">订单金额</label>
            <div class="layui-input-inline">
                <input type="text" name="orderprice"  th:value="${order.orderprice}"  autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-inline">
            <label class="layui-form-label">销量</label>
            <div class="layui-input-inline">
                <input type="text" name="sale" th:value="${order.sale}" autocomplete="off" class="layui-input">
            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">订单日期</label>
            <div class="layui-input-inline">
                <input type="text" name="orderdate"  id="orderdate"  th:value="${order.orderdate}"  placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
            </div>
        </div>



    </div>


</form>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="submit" onclick="doSave()" class="layui-btn" lay-submit="" lay-filter="demo1">更新提交</button>
    </div>
</div>

<!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
<script th:inline="javascript">

    var $,layer;
    layui.use(['form','laydate'],function (){

       var laydate = layui.laydate;
       $=layui.jquery;
       layer=layui.layer;

        //日期
        laydate.render({
            elem: '#orderdate'
        });

        var orderprice=[[${order.orderprice}]]; //收取当前页面的课程名称
        var select='dd[lay-value='+orderprice+']';//属性选择器
        $('#orderprice').siblings("div.layui-form-select").find('dl').find(select).click();


    })

    function doSave() {
       var requestData = $("#form1").serialize();

        $.post("/order/update",requestData,function (responseData) {
            if(responseData.success == 1){
               parent.layer.alert("更新订单成功",{yes:function () {
                       parent.layer.closeAll();
                       window.parent.location.reload();
                   }
               });
            }else {
                parent.layer.alert("更新订单失败",{yes:function () {
                        parent.layer.closeAll();
                        window.parent.location.reload();
                    }
                });

            }
            
        });
    }

</script>

</body>
</html>